#!/usr/bin python3
# -*- coding:UTF-8 -*-
# Author:nigo
def pv(A, r, *n):
    """年金现值函数
    A:年金
    r:利率
    n:期数
    return:现值
    """
    pv = 0
    if len(n) > 1:
        for i in n:
            pv += A / pow((1 + r), i)
    else:
        for i in range(1, n[0] + 1):
            pv += A / pow((1 + r), i)
    return pv


result = pv(5000, 0.04, 1,3,5)
print(result)

